package com.vinjogames.gfx;

import javax.microedition.khronos.opengles.GL10;

import android.graphics.PointF;

import com.vinjogames.util.GameConVars;


public class LoadingScreen {
	
	private LoadingScreen(){};

	private static class LoadingScreenHolder {
		public static final LoadingScreen instance = new LoadingScreen();
	}

	public static LoadingScreen getInstance(){
		return LoadingScreenHolder.instance;
	}
	
	Image mBackground;
	Image mSpinner;
	PointF mLocation;
	PointF mBackLocation;
	boolean mShow;
	
	public void init(){
		mShow = false;
		mSpinner = new Image(GameConVars.UI_SPINNER,4f,4f);
		mBackground = new Image(GameConVars.GRAPHIC_LOADINGSCREEN, Camera.GL_WIDTH, Camera.GL_HEIGHT);
		mSpinner.setAnimations(new int[]{0,7});
		mLocation = new PointF(0,0);//TODO:  center
		mBackLocation = new PointF(0,0);
	}
	
	public boolean draw(GL10 gl){
		if(mShow){
			gl.glPushMatrix();
			gl.glTranslatef(0, 0, Camera.Z_DISTANCE);
			mBackground.draw(gl,mBackLocation);
			//mSpinner.draw(gl, mLocation);
			gl.glPopMatrix();
			return true;
		}
		return false;
	}
	
	public void show(){
		mShow = true;
	}
	
	public void hide(){
		mShow = false;
	}	
}
